﻿function Rectangle(rect){
    this.left = rect.left;
    this.top = rect.top;
    this.right = rect.right;
    this.bottom = rect.bottom;
}

Rectangle.prototype.inside = function(x, y){
    return x >= this.left && x < this.right && y >= this.top && y < this.bottom;
}



function MouseTracker(){
    this.rectangles = [];
    this.eventHandler = {};
    
    function track(e){
        
    }
}

MouseTracker.prototype = {
    rectangles: null,
    eventHandler: null,
    
    add: function(rect){
        this.rectangles.push(new Rectangle(rect));
    },
    
    addEventListener: function(type, handler){
        if(!this.eventHandler[type])
            this.eventHandler[type] = [];
            
        this.eventHandler[type].push(handler);
    },
    
    start: function(){
    }
}


































































/*
function Tooltip(content){
    var self = this;
    var timerId;
    var element;
    
    element = document.createElement("div");
    element.innerHTML = content;
    element.className = "tooltip";
    element.style.position = "absolute";
    element.style.left = 0;
    element.style.top = 0;
    
    document.body.appendChild(element);
    
    this.relatedElement = [];
}

Tooltip.prototype = {
    relatedElement: null,
    
    addRelatedElement: function(){}
};



var timerId;

function documentMouseroverHandler(e){
    var target = e.target;
    var element;
    var content;
    
    do{
        if(content = target.getAttribute("data-tooltip-content")) break;
        if(target === document.documentElement) return;
        
    }while(target = target.parentNode)
    
    timerId = setTimeout(function(){
        element = new Tooltip(content);
    }, 400);
}


function documentMouseoutHandler(e){
    clearTimeout(timerId);
}



document.addEventListener("mouseover", documentMouseroverHandler, true);
document.addEventListener("mouseout", documentMouseoutHandler, true);




*/